// import React, { Component } from 'react'

// export class Login extends Component {
//   render() {
//     return (
//       <div>classfiy</div>
//     )
//   }
// }

// export default Login 
import React, { Component } from 'react'
import { connect } from 'react-redux'
import * as actions from "../store/action"
import { bindActionCreators } from 'redux'
export class Login extends Component {
  componentDidMount() { 
    this.props.getArrAction()
   }
  render() {
    const {num,flag,dianAction,arr}=this.props
    return (
      <div>
        <h1>{num}</h1>
        <button onClick={()=>{this.props.addNumAction()}}>+</button>
         { flag ?'开灯' :'关灯'}
         <button onClick={()=>{
           dianAction()
         }}>开灯</button>
         <ul>
           {arr.length ?arr.map((item,index)=>{
             return <li > <img src={item.img} /></li>
           }) :'暂无数据'}
         </ul>
         
      </div>
    )
  }
}

const mapStateToProps = (state) => ({
...state.reducer
})

const mapDispatchToProps =(dispatch)=> {
  return bindActionCreators(actions,dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(Login)